home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / WIN / VB_DB / PROFIT.ZIP / RECIPMNT.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-03-19  |  40.1 KB  |  1,466 lines

  1. VERSION 2.00
  2. Begin Form RecipMnt 
  3.    BackColor       =   &H00E0FFFF&
  4.    Caption         =   "Recipe File Maintenance"
  5.    Height          =   4905
  6.    Icon            =   RECIPMNT.FRX:0000
  7.    Left            =   210
  8.    LinkMode        =   1  'Source
  9.    LinkTopic       =   "RecipMnt"
  10.    MaxButton       =   0   'False
  11.    MDIChild        =   -1  'True
  12.    ScaleHeight     =   4500
  13.    ScaleWidth      =   9015
  14.    Top             =   1200
  15.    Width           =   9135
  16.    Begin CommandButton CmdRemove 
  17.       Caption         =   "Remo&ve Ingredient"
  18.       Height          =   375
  19.       Left            =   6960
  20.       TabIndex        =   33
  21.       Top             =   3960
  22.       Width           =   1695
  23.    End
  24.    Begin CommandButton CmdClose 
  25.       Caption         =   "&Close"
  26.       Height          =   375
  27.       Left            =   5160
  28.       TabIndex        =   32
  29.       Top             =   3960
  30.       Width           =   855
  31.    End
  32.    Begin CommandButton CmdCancel 
  33.       Cancel          =   -1  'True
  34.       Caption         =   "Cancel"
  35.       FontBold        =   0   'False
  36.       FontItalic      =   0   'False
  37.       FontName        =   "MS Sans Serif"
  38.       FontSize        =   8.25
  39.       FontStrikethru  =   0   'False
  40.       FontUnderline   =   0   'False
  41.       Height          =   375
  42.       Left            =   4320
  43.       TabIndex        =   31
  44.       Top             =   3960
  45.       Width           =   855
  46.    End
  47.    Begin CommandButton CmdDelete 
  48.       Caption         =   "&Delete"
  49.       FontBold        =   0   'False
  50.       FontItalic      =   0   'False
  51.       FontName        =   "MS Sans Serif"
  52.       FontSize        =   8.25
  53.       FontStrikethru  =   0   'False
  54.       FontUnderline   =   0   'False
  55.       Height          =   375
  56.       Left            =   3360
  57.       TabIndex        =   30
  58.       Top             =   3960
  59.       Width           =   855
  60.    End
  61.    Begin CommandButton CmdUpdate 
  62.       Caption         =   "&Update"
  63.       FontBold        =   0   'False
  64.       FontItalic      =   0   'False
  65.       FontName        =   "MS Sans Serif"
  66.       FontSize        =   8.25
  67.       FontStrikethru  =   0   'False
  68.       FontUnderline   =   0   'False
  69.       Height          =   375
  70.       Left            =   2520
  71.       TabIndex        =   29
  72.       Top             =   3960
  73.       Width           =   855
  74.    End
  75.    Begin CommandButton CmdAdd 
  76.       Caption         =   "&Add"
  77.       FontBold        =   0   'False
  78.       FontItalic      =   0   'False
  79.       FontName        =   "MS Sans Serif"
  80.       FontSize        =   8.25
  81.       FontStrikethru  =   0   'False
  82.       FontUnderline   =   0   'False
  83.       Height          =   375
  84.       Left            =   1680
  85.       TabIndex        =   28
  86.       Top             =   3960
  87.       Width           =   855
  88.    End
  89.    Begin CommandButton CmdNext 
  90.       BackColor       =   &H00FFFFFF&
  91.       Caption         =   "&Next"
  92.       FontBold        =   0   'False
  93.       FontItalic      =   0   'False
  94.       FontName        =   "MS Sans Serif"
  95.       FontSize        =   8.25
  96.       FontStrikethru  =   0   'False
  97.       FontUnderline   =   0   'False
  98.       Height          =   375
  99.       Left            =   840
  100.       TabIndex        =   27
  101.       TabStop         =   0   'False
  102.       Top             =   3960
  103.       Width           =   735
  104.    End
  105.    Begin CommandButton CmdPrevious 
  106.       Caption         =   "&Previous"
  107.       FontBold        =   0   'False
  108.       FontItalic      =   0   'False
  109.       FontName        =   "MS Sans Serif"
  110.       FontSize        =   8.25
  111.       FontStrikethru  =   0   'False
  112.       FontUnderline   =   0   'False
  113.       Height          =   375
  114.       Left            =   120
  115.       TabIndex        =   26
  116.       TabStop         =   0   'False
  117.       Top             =   3960
  118.       Width           =   735
  119.    End
  120.    Begin Grid Grid1 
  121.       Cols            =   5
  122.       Enabled         =   0   'False
  123.       FixedCols       =   0
  124.       FixedRows       =   0
  125.       Height          =   1455
  126.       Left            =   120
  127.       ScrollBars      =   0  'None
  128.       TabIndex        =   22
  129.       Top             =   1920
  130.       Width           =   8535
  131.    End
  132.    Begin TextBox TxtUnits 
  133.       Height          =   375
  134.       Left            =   5520
  135.       TabIndex        =   19
  136.       Top             =   1440
  137.       Width           =   975
  138.    End
  139.    Begin TextBox TxtIngKey 
  140.       Height          =   375
  141.       Left            =   120
  142.       TabIndex        =   17
  143.       Top             =   1440
  144.       Width           =   2175
  145.    End
  146.    Begin TextBox TxtLife 
  147.       Height          =   375
  148.       Left            =   7920
  149.       TabIndex        =   15
  150.       Top             =   600
  151.       Width           =   735
  152.    End
  153.    Begin TextBox TxtMaintCode 
  154.       Height          =   375
  155.       Left            =   6240
  156.       TabIndex        =   13
  157.       Top             =   600
  158.       Width           =   735
  159.    End
  160.    Begin TextBox TxtTarget 
  161.       Height          =   375
  162.       Left            =   4200
  163.       TabIndex        =   11
  164.       Top             =   600
  165.       Width           =   735
  166.    End
  167.    Begin TextBox TxtYields 
  168.       Height          =   375
  169.       Left            =   2520
  170.       TabIndex        =   9
  171.       Top             =   600
  172.       Width           =   615
  173.    End
  174.    Begin TextBox TxtRetail 
  175.       Height          =   375
  176.       Left            =   840
  177.       TabIndex        =   7
  178.       Top             =   600
  179.       Width           =   855
  180.    End
  181.    Begin TextBox TxtGroup 
  182.       Height          =   375
  183.       Left            =   7920
  184.       TabIndex        =   5
  185.       Top             =   120
  186.       Width           =   735
  187.    End
  188.    Begin TextBox TxtDesc 
  189.       Height          =   375
  190.       Left            =   3480
  191.       TabIndex        =   3
  192.       Top             =   120
  193.       Width           =   3495
  194.    End
  195.    Begin TextBox TxtKey 
  196.       Height          =   375
  197.       Left            =   1320
  198.       TabIndex        =   1
  199.       Top             =   120
  200.       Width           =   855
  201.    End
  202.    Begin Line Line2 
  203.       X1              =   120
  204.       X2              =   8760
  205.       Y1              =   3480
  206.       Y2              =   3480
  207.    End
  208.    Begin Line Line1 
  209.       X1              =   120
  210.       X2              =   8760
  211.       Y1              =   1080
  212.       Y2              =   1080
  213.    End
  214.    Begin Label LblProfitMargin 
  215.       BackColor       =   &H00E0FFFF&
  216.       Caption         =   "Profit Margin = "
  217.       Height          =   255
  218.       Left            =   5760
  219.       TabIndex        =   25
  220.       Top             =   3600
  221.       Width           =   2895
  222.    End
  223.    Begin Label LblUnitCost 
  224.       BackColor       =   &H00E0FFFF&
  225.       Caption         =   "Unit Cost ="
  226.       Height          =   255
  227.       Left            =   2760
  228.       TabIndex        =   24
  229.       Top             =   3600
  230.       Width           =   2775
  231.    End
  232.    Begin Label LblTotalCost 
  233.       BackColor       =   &H00E0FFFF&
  234.       Caption         =   "Total Cost ="
  235.       Height          =   255
  236.       Left            =   120
  237.       TabIndex        =   23
  238.       Top             =   3600
  239.       Width           =   2535
  240.    End
  241.    Begin Label LblIngCost 
  242.       BackColor       =   &H00E0FFFF&
  243.       Height          =   255
  244.       Left            =   7920
  245.       TabIndex        =   21
  246.       Top             =   1560
  247.       Width           =   735
  248.    End
  249.    Begin Label LblIngUnitDesc 
  250.       BackColor       =   &H00E0FFFF&
  251.       Height          =   255
  252.       Left            =   6600
  253.       TabIndex        =   20
  254.       Top             =   1560
  255.       Width           =   1095
  256.    End
  257.    Begin Label LblIngDesc 
  258.       BackColor       =   &H00E0FFFF&
  259.       Height          =   255
  260.       Left            =   2400
  261.       TabIndex        =   18
  262.       Top             =   1560
  263.       Width           =   3015
  264.    End
  265.    Begin Label LblHeadings 
  266.       BackColor       =   &H00E0FFFF&
  267.       Caption         =   "V#    &Ingredient#            Description                                      # Units                            Cost"
  268.       Height          =   255
  269.       Left            =   240
  270.       TabIndex        =   16
  271.       Top             =   1080
  272.       Width           =   8415
  273.    End
  274.    Begin Label LblLife 
  275.       Alignment       =   1  'Right Justify
  276.       BackColor       =   &H00E0FFFF&
  277.       Caption         =   "&Life:"
  278.       Height          =   255
  279.       Left            =   7320
  280.       TabIndex        =   14
  281.       Top             =   720
  282.       Width           =   495
  283.    End
  284.    Begin Label LblMaintCode 
  285.       Alignment       =   1  'Right Justify
  286.       BackColor       =   &H00E0FFFF&
  287.       Caption         =   "&Maint Code:"
  288.       Height          =   255
  289.       Left            =   5040
  290.       TabIndex        =   12
  291.       Top             =   720
  292.       Width           =   1095
  293.    End
  294.    Begin Label LblTarget 
  295.       Alignment       =   1  'Right Justify
  296.       BackColor       =   &H00E0FFFF&
  297.       Caption         =   "&Target %:"
  298.       Height          =   255
  299.       Left            =   3240
  300.       TabIndex        =   10
  301.       Top             =   720
  302.       Width           =   855
  303.    End
  304.    Begin Label LblYields 
  305.       Alignment       =   1  'Right Justify
  306.       BackColor       =   &H00E0FFFF&
  307.       Caption         =   "&Yields:"
  308.       Height          =   255
  309.       Left            =   1800
  310.       TabIndex        =   8
  311.       Top             =   720
  312.       Width           =   615
  313.    End
  314.    Begin Label LblRetail 
  315.       Alignment       =   1  'Right Justify
  316.       BackColor       =   &H00E0FFFF&
  317.       Caption         =   "&Retail:"
  318.       Height          =   255
  319.       Left            =   120
  320.       TabIndex        =   6
  321.       Top             =   720
  322.       Width           =   615
  323.    End
  324.    Begin Label LblDesc 
  325.       Alignment       =   1  'Right Justify
  326.       BackColor       =   &H00E0FFFF&
  327.       Caption         =   "D&escription:"
  328.       Height          =   255
  329.       Left            =   2280
  330.       TabIndex        =   2
  331.       Top             =   240
  332.       Width           =   1095
  333.    End
  334.    Begin Label LblKey 
  335.       Alignment       =   1  'Right Justify
  336.       BackColor       =   &H00E0FFFF&
  337.       Caption         =   "Recipe &Key:"
  338.       Height          =   255
  339.       Left            =   120
  340.       TabIndex        =   0
  341.       Top             =   240
  342.       Width           =   1095
  343.    End
  344.    Begin Label LblGroup 
  345.       Alignment       =   1  'Right Justify
  346.       BackColor       =   &H00E0FFFF&
  347.       Caption         =   "&Group:"
  348.       Height          =   255
  349.       Left            =   7080
  350.       TabIndex        =   4
  351.       Top             =   120
  352.       Width           =   735
  353.    End
  354. '*************************************************************
  355. '*  Form Name:  RecipMnt                                     *
  356. '*  Performs file maintenance to Recipe file.                *
  357. '*************************************************************
  358.   Dim EntryMode As String * 1
  359.   Dim FieldError As Integer
  360.   Dim DetailSaved As Integer
  361.   Dim SkipScreenUpdate As Integer
  362. Sub CalculateTotals ()
  363.   SkipScreenUpdate = True
  364.   On Local Error GoTo CalcError
  365.   SaveGridRow% = Grid1.Row
  366.   SaveGridCol% = Grid1.Col
  367.   TotalCost@ = 0
  368.   Grid1.Col = 4
  369.   For I% = 0 To Grid1.Rows - 2
  370.     Grid1.Row = I%
  371.     TotalCost@ = TotalCost@ + Val(Grid1.Text)
  372.   Next I%
  373.   LblTotalCost.Caption = "Total Cost = " + Format$(TotalCost@, "###0.0000")
  374.   UnitCost@ = TotalCost@ / Val(TxtYields.Text)
  375.   LblUnitCost.Caption = "Unit Cost = " + Format$(UnitCost@, "###0.0000")
  376.   Retail@ = Val(TxtRetail.Text)
  377.   ProfitMargin@ = ((Retail@ - UnitCost@) / Retail@) * 100
  378.   LblProfitMargin.Caption = "Profit Margin = " + Format$(ProfitMargin@, "##0.00")
  379.   Grid1.Row = SaveGridRow%
  380.   Grid1.Col = SaveGridCol%
  381.   SkipScreenUpdate = False
  382.   Grid1_RowColChange
  383.   Exit Sub
  384. CalcError:
  385.   Resume CalcErrorEnd
  386. CalcErrorEnd:
  387.   LblTotalCost.Caption = "Total Cost = "
  388.   LblUnitCost.Caption = "Unit Cost = "
  389.   LblProfitMargin.Caption = "Profit Margin = "
  390.   SkipScreenUpdate = False
  391.   Grid1_RowColChange
  392. End Sub
  393. Sub ClearAllFields ()
  394.   EntryMode = "N"
  395.   TxtKey.Text = ""
  396.   ClearDataFields
  397.   TxtKey.SetFocus
  398.   SetCmdFlags
  399.   LblTotalCost.Caption = "Total Cost = "
  400.   LblUnitCost.Caption = "Unit Cost = "
  401.   LblProfitMargin.Caption = "Profit Margin = "
  402. End Sub
  403. Sub ClearDataFields ()
  404.   Cls
  405.   SkipScreenUpdate = True
  406.   TxtDesc.Text = ""
  407.   TxtGroup.Text = ""
  408.   TxtRetail.Text = ""
  409.   TxtYields.Text = ""
  410.   TxtTarget.Text = ""
  411.   TxtMaintCode.Text = ""
  412.   TxtLife.Text = ""
  413.   TxtIngKey.Text = ""
  414.   TxtUnits.Text = ""
  415.   LblIngDesc.Caption = ""
  416.   LblIngUnitDesc.Caption = ""
  417.   LblIngCost.Caption = ""
  418.   T1% = Grid1.Rows - 2
  419.   For I% = 0 To T1%
  420.     Grid1.RemoveItem 0
  421.   Next I%
  422.   For I% = 0 To 4
  423.     Grid1.Col = I%
  424.     Grid1.Text = ""
  425.   Next I%
  426.   SkipScreenUpdate = False
  427.   Grid1_RowColChange
  428. End Sub
  429. Sub CmdAdd_Click ()
  430.     ErrorCheckFields
  431.     MoveFieldsToRecord
  432.     If Not FieldError Then
  433.     WriteRecipe
  434.     Select Case RecipeSt%
  435.       Case 0
  436.         ClearAllFields
  437.         EndTransaction
  438.       Case 3
  439.         MsgRecipeNotOpen
  440.       Case 5
  441.         Msg$ = "Recipe already on file."
  442.         T1% = MsgBox(Msg$, 0, "Note")
  443.         TxtDesc.SetFocus
  444.       Case Else
  445.         MsgUnknownRecipeError
  446.     End Select
  447.     End If
  448. End Sub
  449. Sub CmdCancel_Click ()
  450.   If ActiveTransaction Then
  451.     AbortTransaction
  452.   End If
  453.   ClearAllFields
  454. End Sub
  455. Sub CmdClose_Click ()
  456.   If EntryMode = "C" Then
  457.     Msg$ = "Record has not been updated." + Chr$(13)
  458.     Msg$ = "Do you want to update the record?"
  459.     TI% = MsgBox(Msg$, 260, "Message")
  460.   End If
  461.   If TI% <> 6 Then
  462.     Unload RecipMnt
  463.   End If
  464. End Sub
  465. Sub CmdDelete_Click ()
  466.     Msg$ = "Are you sure?"
  467.     TI% = MsgBox(Msg$, 260, "Delete?")
  468.     If TI% = 6 Then
  469.       DeleteRecipeDetail
  470.       DeleteRecipe
  471.       SalesMixRec.RecNo = RecipeRec.RecNo
  472.       ReadSalesMix
  473.       DeleteSalesMix
  474.       EndTransaction
  475.       Select Case RecipeSt%
  476.     Case 0
  477.       ClearAllFields
  478.     Case 8
  479.       Msg$ = "Record must be found before you can delete."
  480.       Beep
  481.       T1% = MsgBox(Msg$, 0, "Warning!")
  482.     Case 80
  483.       Msg$ = "This record updated since read. Reread and try again."
  484.       Beep
  485.       T1% = MsgBox(Msg$, 0, "Not Deleted!")
  486.     Case Else
  487.       Msg$ = "Recipe not deleted.  Status = " + Str$(RecipeSt%)
  488.       Beep
  489.       T1% = MsgBox(Msg$, 0, "Warning!")
  490.       End Select
  491.     End If
  492. End Sub
  493. Sub CmdNext_Click ()
  494.   Screen.MousePointer = 11
  495.   If ActiveTransaction Then
  496.     AbortTransaction
  497.   End If
  498.   ClearDataFields
  499.   NextRecipe
  500.   Select Case RecipeSt%
  501.     Case 0
  502.       DisplayDataFields
  503.       ReadAllRecipeDet
  504.       BeginTransaction
  505.     Case 3
  506.       Screen.MousePointer = 0
  507.       MsgRecipeNotOpen
  508.     Case 8
  509.       FirstRecipe
  510.       If RecipeSt% <> 0 Then
  511.     Screen.MousePointer = 0
  512.     MsgUnknownRecipeError
  513.       Else
  514.     DisplayDataFields
  515.     ReadAllRecipeDet
  516.     BeginTransaction
  517.       End If
  518.     Case 9
  519.       Screen.MousePointer = 0
  520.       ClearAllFields
  521.       Msg$ = "End of Recipe file."
  522.       T1% = MsgBox(Msg$, 0, "Note")
  523.     Case Else
  524.       Screen.MousePointer = 0
  525.       MsgUnknownRecipeError
  526.   End Select
  527.   SetCmdFlags
  528.   Screen.MousePointer = 0
  529. End Sub
  530. Sub CmdPrevious_Click ()
  531.   Screen.MousePointer = 11
  532.   If ActiveTransaction Then
  533.     AbortTransaction
  534.   End If
  535.   ClearDataFields
  536.   PreviousRecipe
  537.   Select Case RecipeSt%
  538.     Case 0
  539.       DisplayDataFields
  540.       ReadAllRecipeDet
  541.       BeginTransaction
  542.     Case 3
  543.       Screen.MousePointer = 0
  544.       MsgRecipeNotOpen
  545.     Case 8
  546.       FirstRecipe
  547.       If RecipeSt% <> 0 Then
  548.     Screen.MousePointer = 0
  549.     MsgUnknownRecipeError
  550.       Else
  551.     DisplayDataFields
  552.     ReadAllRecipeDet
  553.     BeginTransaction
  554.       End If
  555.     Case 9
  556.       Screen.MousePointer = 0
  557.       ClearAllFields
  558.       Msg$ = "Beginning of Recipe file."
  559.       T1% = MsgBox(Msg$, 0, "Note")
  560.     Case Else
  561.       Screen.MousePointer = 0
  562.       MsgUnknownRecipeError
  563.   End Select
  564.   Screen.MousePointer = 0
  565.   SetCmdFlags
  566. End Sub
  567. Sub CmdRemove_Click ()
  568.    If Grid1.Rows > 1 Then
  569.      If Grid1.Row <> Grid1.Rows - 1 Then
  570.        RecipeDetRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
  571.        ReadRecipeDet
  572.        If RecipeDetSt% <> 0 Then
  573.      MsgUnknownRecipeDetError
  574.        Else
  575.      DeleteRecipeDet
  576.      Grid1.RemoveItem Grid1.Row
  577.      Grid1.Col = 0
  578.      TxtIngKey.Text = Grid1.Text
  579.      Grid1.Col = 1
  580.      LblIngDesc.Caption = Grid1.Text
  581.      Grid1.Col = 2
  582.      TxtUnits.Text = Grid1.Text
  583.      Grid1.Col = 3
  584.      LblIngUnitDesc.Caption = Grid1.Text
  585.      Grid1.Col = 4
  586.      LblIngCost.Caption = Grid1.Text
  587.      CalculateTotals
  588.        End If
  589.      End If
  590.    End If
  591.    TxtIngKey.SetFocus
  592. End Sub
  593. Sub CmdUpdate_Click ()
  594.     EntryMode = "C"
  595.     ErrorCheckFields
  596.     If Not FieldError Then
  597.       MoveFieldsToRecord
  598.       UpdateRecipe
  599.       Select Case RecipeSt%
  600.     Case 0
  601.       EntryMode = "N"
  602.       ClearAllFields
  603.       EndTransaction
  604.     Case 3
  605.       MsgRecipeNotOpen
  606.     Case 5
  607.       Msg$ = "Recipe duplicate on file."
  608.       T1% = MsgBox(Msg$, 0, "Note")
  609.     Case 8
  610.       Msg$ = "Update only works on found records."
  611.       T1% = MsgBox(Msg$, 0, "Note")
  612.     Case 80
  613.       Msg$ = "This record updated since read. Reread and try again."
  614.       T1% = MsgBox(Msg$, 0, "Warning!")
  615.     Case Else
  616.       MsgUnknownRecipeError
  617.       End Select
  618.     End If
  619. End Sub
  620. Sub DeleteRecipeDetail ()
  621.    RecipeDetRec.RecDetKey = RecipeRec.RecNo + String$(15, "0")
  622.    GetGERecipeDet
  623.    If RecipeDetSt% = 9 Then
  624.      Exit Sub
  625.    End If
  626.    If RecipeDetSt% <> 0 Then
  627.      MsgUnknownRecipeDetError
  628.    End If
  629.    Do Until RecipeDetSt% <> 0 Or RecipeDetRec.RecDetKey > RecipeRec.RecNo + String$(15, "Z")
  630.        DeleteRecipeDet
  631.        NextRecipeDet
  632.    Loop
  633. End Sub
  634. Sub DisplayDataFields ()
  635.     SkipScreenUpdate = True
  636.     RecipeSaveRec = RecipeRec
  637.     TxtKey.Text = RecipeRec.RecNo
  638.     TxtDesc.Text = RecipeRec.RecDesc
  639.     TxtGroup.Text = RecipeRec.RecGroup
  640.     TxtRetail.Text = Format$((RecipeRec.RecRetail / 100), "###.00")
  641.     TxtYields.Text = Format$(RecipeRec.Servings, "##0")
  642.     TxtTarget.Text = Format$((RecipeRec.TargetProfit * 100), "###.00")
  643.     TxtMaintCode.Text = RecipeRec.MaintenanceCode
  644.     TxtLife.Text = Format$(RecipeRec.ShelfLifeDays, "#0")
  645.     TxtRetail.SetFocus
  646.     EntryMode = "U"
  647.     SkipScreenUpdate = False
  648. End Sub
  649. Sub ErrorCheckFields ()
  650.   FieldError = False
  651.   If LTrim$(RTrim$(TxtKey.Text)) = "" Then
  652.     Msg$ = "Recipe number is required."
  653.     T1% = MsgBox(Msg$, 0, "Note")
  654.     FieldError = True
  655.     TxtKey.SetFocus
  656.     Exit Sub
  657.   End If
  658.   If LTrim$(RTrim$(TxtDesc.Text)) = "" Then
  659.     Msg$ = "Description is required."
  660.     T1% = MsgBox(Msg$, 0, "Note")
  661.     FieldError = True
  662.     TxtDesc.SetFocus
  663.     Exit Sub
  664.   End If
  665.   If LTrim$(RTrim$(TxtGroup.Text)) = "" Then
  666.     Msg$ = "Recipe group is required."
  667.     T1% = MsgBox(Msg$, 0, "Note")
  668.     FieldError = True
  669.     TxtGroup.SetFocus
  670.     Exit Sub
  671.   End If
  672.   RecGroupRec.RecGroup = LTrim$(RTrim$(TxtGroup.Text))
  673.   ReadRecGroup
  674.   If RecGroupSt% <> 0 Then
  675.     Msg$ = "Recipe group is not valid."
  676.     T1% = MsgBox(Msg$, 0, "Note")
  677.     FieldError = True
  678.     TxtGroup.SetFocus
  679.     Exit Sub
  680.   End If
  681.   If LTrim$(RTrim$(TxtRetail.Text)) = "" Then
  682.     Msg$ = "You must have a retail."
  683.     T1% = MsgBox(Msg$, 0, "Note")
  684.     FieldError = True
  685.     TxtRetail.SetFocus
  686.     Exit Sub
  687.   End If
  688.   If LTrim$(RTrim$(TxtYields.Text)) = "" Then
  689.     Msg$ = "You must servings per recipe."
  690.     T1% = MsgBox(Msg$, 0, "Note")
  691.     FieldError = True
  692.     TxtYields.SetFocus
  693.     Exit Sub
  694.   End If
  695.   If LTrim$(RTrim$(TxtTarget.Text)) = "" Then
  696.     Msg$ = "You must enter a target gross profit."
  697.     T1% = MsgBox(Msg$, 0, "Note")
  698.     FieldError = True
  699.     TxtTarget.SetFocus
  700.     Exit Sub
  701.   Else
  702.     Test@ = Val(TxtTarget.Text)
  703.     If Test@ < .01 Or Test@ > 100# Then
  704.       Beep
  705.       Msg$ = "Target profit must be between .01 and 100.00"
  706.       MsgBox Msg$, 0, "Warning"
  707.       FieldError = True
  708.       TxtTarget.SetFocus
  709.       Exit Sub
  710.     End If
  711.   End If
  712.   If LTrim$(RTrim$(TxtMaintCode.Text)) = "" Then
  713.     Msg$ = "You must enter a maintenance code."
  714.     T1% = MsgBox(Msg$, 0, "Note")
  715.     FieldError = True
  716.     TxtMaintCode.SetFocus
  717.     Exit Sub
  718.   End If
  719.   Select Case UCase$(LTrim$(RTrim$(TxtMaintCode.Text)))
  720.     Case "N", "D", "M"
  721.     Case Else
  722.       Msg$ = "Maint Code must be:" + Chr$(10)
  723.       Msg$ = Msg$ + "N - Round to nine" + Chr$(10)
  724.       Msg$ = Msg$ + "D - Round to dollar 99" + Chr$(10)
  725.       Msg$ = Msg$ + "M - Manual calculation"
  726.       T1% = MsgBox(Msg$, 0, "Note")
  727.       FieldError = True
  728.       TxtMaintCode.SetFocus
  729.       Exit Sub
  730.   End Select
  731.   If LTrim$(RTrim$(TxtLife.Text)) = "" Then
  732.     Msg$ = "You must enter a shelf life."
  733.     T1% = MsgBox(Msg$, 0, "Note")
  734.     FieldError = True
  735.     TxtLife.SetFocus
  736.     Exit Sub
  737.   End If
  738. End Sub
  739. Sub Form_Activate ()
  740.   RecipeRec.RecNo = TxtKey.Text + String$(6 - Len(TxtKey.Text), " ")
  741.   ReadRecipe
  742.   IngredientRec.IngKey = TxtIngKey.Text + String$(18 - Len(TxtIngKey.Text), " ")
  743.   RecipeDetRec.RecDetKey = RecipeRec.RecNo + IngredientRec.IngKey
  744.   ReadRecipeDet
  745. End Sub
  746. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  747.     If KeyCode = KEY_F4 Then    ' Display key combinations.
  748.       If TxtDesc.Text <> "" Then
  749.     TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
  750.     TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
  751.       End If
  752.     End If
  753. End Sub
  754. Sub Form_Load ()
  755.     RecipMnt.Top = DeliMain.Top
  756.     RecipMnt.Left = DeliMain.Left
  757.     RecipMnt.Height = 4905
  758.     RecipMnt.Width = 8985
  759.     EntryMode = "N"
  760.     SkipScreenUpdate = False
  761.     Grid1.ColWidth(0) = 2150
  762.     Grid1.ColWidth(1) = 3225
  763.     Grid1.ColWidth(2) = 950
  764.     Grid1.ColAlignment(2) = 1
  765.     Grid1.ColWidth(3) = 1200
  766.     Grid1.ColWidth(4) = 925
  767.     Grid1.ColAlignment(4) = 1
  768.     Grid1.Row = 0
  769.     Grid1.RowHeight(0) = Grid1.Height / 6.47
  770.     Grid1_RowColChange
  771.     Screen.MousePointer = 0
  772. End Sub
  773. Sub Form_Unload (Cancel As Integer)
  774.   If ActiveTransaction Then
  775.     AbortTransaction
  776.   End If
  777. End Sub
  778. Sub Grid1_KeyDown (KeyCode As Integer, Shift As Integer)
  779.   If KeyCode = KEY_UP Then
  780.     ScrollGridUp
  781.     If Grid1.Text <> "" Then
  782.       Grid1.Col = 0
  783.       RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
  784.       RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
  785.       DetailSaved = True
  786.     Else
  787.       DetailSaved = False
  788.     End If
  789.     KeyCode = 0
  790.   ElseIf KeyCode = KEY_DOWN Then
  791.     ScrollGridDown
  792.     If Grid1.Text <> "" Then
  793.       Grid1.Col = 0
  794.       RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
  795.       RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
  796.       DetailSaved = True
  797.     Else
  798.       DetailSaved = False
  799.     End If
  800.     KeyCode = 0
  801.   End If
  802. End Sub
  803. Sub Grid1_RowColChange ()
  804.   If Not SkipScreenUpdate Then
  805.     Grid1.SelStartCol = 0
  806.     Grid1.SelEndCol = 4
  807.     Grid1.SelStartRow = Grid1.Row
  808.     Grid1.SelEndRow = Grid1.Row
  809.   End If
  810. End Sub
  811. Sub MoveFieldsToRecord ()
  812.     RecipeRec.RecNo = TxtKey.Text + String$(6 - Len(TxtKey.Text), " ")
  813.     RecipeRec.RecDesc = TxtDesc.Text
  814.     RecipeRec.RecGroup = TxtGroup.Text
  815.     RecipeRec.RecRetail = Val(TxtRetail.Text) * 100
  816.     RecipeRec.Servings = Val(TxtYields.Text)
  817.     RecipeRec.TargetProfit = Val(TxtTarget.Text) / 100
  818.     RecipeRec.MaintenanceCode = TxtMaintCode.Text
  819.     RecipeRec.ShelfLifeDays = Val(TxtLife.Text)
  820. End Sub
  821. Sub ReadAllRecipeDet ()
  822.    SkipScreenUpdate = True
  823.    DetailSaved = False
  824.    RecipeDetRec.RecDetKey = RecipeRec.RecNo + String$(15, "0")
  825.    GetGERecipeDet
  826.    If RecipeDetSt% = 9 Then
  827.      Exit Sub
  828.    End If
  829.    If RecipeDetSt% <> 0 Then
  830.      MsgUnknownRecipeDetError
  831.    End If
  832.    Do Until RecipeDetSt% <> 0 Or RecipeDetRec.RecDetKey > RecipeRec.RecNo + String$(15, "Z")
  833.        IngredientRec.IngKey = Mid$(RecipeDetRec.RecDetKey, 7, 15)
  834.        ReadIngredient
  835.        If IngredientSt% = 0 Then
  836.      GoSub AddToGrid
  837.        End If
  838.        NextRecipeDet
  839.    Loop
  840.    SkipScreenUpdate = False
  841.    Grid1_RowColChange
  842.    CalculateTotals
  843.    Exit Sub
  844. AddToGrid:
  845.   If Grid1.Row = Grid1.Rows - 1 Then
  846.     Grid1.AddItem "", Grid1.Rows
  847.     Grid1.RowHeight(Grid1.Row + 1) = Grid1.Height / 6.47
  848.   End If
  849.   Grid1.Col = 0
  850.   Grid1.Text = IngredientRec.IngKey
  851.   Grid1.Col = 1
  852.   Grid1.Text = RTrim$(IngredientRec.IngDesc)
  853.   Grid1.Col = 2
  854.   Grid1.Text = Format$(RecipeDetRec.RecDetQty, "##0.00")
  855.   Grid1.Col = 3
  856.   Grid1.Text = RTrim$(IngredientRec.IngUnitDesc)
  857.   Cost& = IngredientRec.IngCaseCost / IngredientRec.IngUnitsPerCase
  858.   Cost& = Cost& * RecipeDetRec.RecDetQty
  859.   LblIngCost.Caption = Format$(Cost& / 10000, "###.0000")
  860.   Grid1.Col = 4
  861.   Grid1.Text = LblIngCost.Caption
  862.   ScrollGridDown
  863. Return
  864. End Sub
  865. Sub ScrollGridDown ()
  866.     If Grid1.Row < Grid1.Rows - 1 Then
  867.       Grid1.Row = Grid1.Row + 1
  868.       If Grid1.Rows > 6 Then
  869.     If Grid1.Row > Grid1.Rows - 3 Then
  870.       Grid1.TopRow = Grid1.Rows - 5
  871.     Else
  872.       If Grid1.Row < 3 Then
  873.         Grid1.TopRow = 0
  874.       Else
  875.         Grid1.TopRow = Grid1.Row - 3
  876.       End If
  877.     End If
  878.       End If
  879.     End If
  880.     Grid1.Col = 0
  881.     TxtIngKey.Text = RTrim$(Grid1.Text)
  882.     Grid1.Col = 1
  883.     LblIngDesc.Caption = Grid1.Text
  884.     Grid1.Col = 2
  885.     TxtUnits.Text = Grid1.Text
  886.     Grid1.Col = 3
  887.     LblIngUnitDesc.Caption = Grid1.Text
  888.     Grid1.Col = 4
  889.     LblIngCost.Caption = Grid1.Text
  890.     TxtIngKey.SelStart = 0
  891.     TxtIngKey.SelLength = Len(TxtIngKey.Text)
  892.     Grid1.Col = 0
  893. End Sub
  894. Sub ScrollGridUp ()
  895.     If Grid1.Row > 0 Then
  896.       Grid1.Row = Grid1.Row - 1
  897.       If Grid1.Rows > 6 Then
  898.     If Grid1.Row < 3 Then
  899.       Grid1.TopRow = 0
  900.     Else
  901.       Grid1.TopRow = Grid1.Row - 3
  902.     End If
  903.       End If
  904.     End If
  905.     Grid1.Col = 0
  906.     TxtIngKey.Text = RTrim$(Grid1.Text)
  907.     Grid1.Col = 1
  908.     LblIngDesc.Caption = Grid1.Text
  909.     Grid1.Col = 2
  910.     TxtUnits.Text = Grid1.Text
  911.     Grid1.Col = 3
  912.     LblIngUnitDesc.Caption = Grid1.Text
  913.     Grid1.Col = 4
  914.     LblIngCost.Caption = Grid1.Text
  915.     Grid1.Col = 0
  916.     TxtIngKey.SelStart = 0
  917.     TxtIngKey.SelLength = Len(TxtIngKey.Text)
  918. End Sub
  919. Sub SetCmdFlags ()
  920.  If Not SkipScreenUpdate Then
  921.   Select Case EntryMode
  922.     Case "N"
  923.       CmdPrevious.Enabled = True
  924.       CmdNext.Enabled = True
  925.       CmdCancel.Enabled = False
  926.       CmdAdd.Enabled = True
  927.       CmdUpdate.Enabled = False
  928.       CmdDelete.Enabled = False
  929.     Case "U"
  930.       CmdPrevious.Enabled = True
  931.       CmdNext.Enabled = True
  932.       CmdCancel.Enabled = False
  933.       CmdAdd.Enabled = False
  934.       CmdUpdate.Enabled = True
  935.       CmdDelete.Enabled = True
  936.     Case "C"
  937.       CmdPrevious.Enabled = True
  938.       CmdNext.Enabled = True
  939.       CmdCancel.Enabled = True
  940.       CmdAdd.Enabled = False
  941.       CmdUpdate.Enabled = True
  942.       CmdDelete.Enabled = False
  943.     Case Else
  944.       Msg$ = "Undefined Entry Mode Flag - " + EntryMode + "."
  945.       T1% = MsgBox(Msg$, 0, "Warning!")
  946.   End Select
  947.  End If
  948. End Sub
  949. Sub TxtDesc_Change ()
  950.   If EntryMode = "U" Then
  951.     EntryMode = "C"
  952.     SetCmdFlags
  953.   End If
  954. End Sub
  955. Sub TxtDesc_GotFocus ()
  956.   TxtDesc.SelStart = 0
  957.   TxtDesc.SelLength = Len(TxtDesc.Text)
  958. End Sub
  959. Sub TxtDesc_KeyDown (KeyCode As Integer, Shift As Integer)
  960.     If KeyCode = KEY_F4 Then    ' Display key combinations.
  961.       If TxtDesc.Text <> "" Then
  962.     TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
  963.     TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
  964.       End If
  965.     End If
  966.     If KeyCode = KEY_PAGE_UP Then
  967.     CmdPrevious_Click
  968.     End If
  969.     If KeyCode = KEY_PAGE_DOWN Then
  970.     CmdNext_Click
  971.     End If
  972. End Sub
  973. Sub TxtDesc_KeyPress (KeyAscii As Integer)
  974.   If KeyAscii = 13 Then
  975.     KeyAscii = 0
  976.     TxtGroup.SetFocus
  977.   ElseIf Chr$(KeyAscii) = "-" Then
  978.     KeyAscii = 0
  979.     Beep
  980.   Else
  981.     StrKP TxtDesc, 30, KeyAscii
  982.     KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
  983.   End If
  984. End Sub
  985. Sub TxtGroup_Change ()
  986.   If EntryMode = "U" Then
  987.     EntryMode = "C"
  988.     SetCmdFlags
  989.   End If
  990. End Sub
  991. Sub TxtGroup_GotFocus ()
  992.   TxtGroup.SelStart = 0
  993.   TxtGroup.SelLength = Len(TxtGroup.Text)
  994. End Sub
  995. Sub TxtGroup_KeyDown (KeyCode As Integer, Shift As Integer)
  996.     If KeyCode = KEY_F4 Then    ' Display key combinations.
  997.       If TxtDesc.Text <> "" Then
  998.     TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
  999.     TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
  1000.       End If
  1001.     End If
  1002.     If KeyCode = KEY_PAGE_UP Then
  1003.     CmdPrevious_Click
  1004.     End If
  1005.     If KeyCode = KEY_PAGE_DOWN Then
  1006.     CmdNext_Click
  1007.     End If
  1008. End Sub
  1009. Sub TxtGroup_KeyPress (KeyAscii As Integer)
  1010.   If KeyAscii = 13 Then
  1011.     KeyAscii = 0
  1012.     TxtRetail.SetFocus
  1013.   Else
  1014.     IntKP TxtGroup, 4, KeyAscii
  1015.   End If
  1016. End Sub
  1017. Sub TxtGroup_LostFocus ()
  1018.   If TxtGroup.Text = "" Then
  1019.     If RecipeSaveRec.RecGroup <> "    " Then
  1020.       TxtGroup.Text = RecipeSaveRec.RecGroup
  1021.     End If
  1022.   End If
  1023.   If TxtGroup.Text <> "" Then
  1024.     RecGroupRec.RecGroup = String$(4 - Len(TxtGroup.Text), "0") + TxtGroup.Text
  1025.     TxtGroup.Text = RecGroupRec.RecGroup
  1026.     ReadRecGroup
  1027.     Select Case RecGroupSt%
  1028.       Case 0
  1029.       Case 3
  1030.     MsgRecGroupNotOpen
  1031.       Case 4
  1032.     MsgRecGroupNotFound
  1033.     TxtGroup.SetFocus
  1034.       Case Else
  1035.     MsgUnknownRecGroupError
  1036.     End Select
  1037.   End If
  1038. End Sub
  1039. Sub TxtIngKey_Change ()
  1040.   If EntryMode = "U" Then
  1041.     EntryMode = "C"
  1042.     SetCmdFlags
  1043.   End If
  1044. End Sub
  1045. Sub TxtIngKey_GotFocus ()
  1046.    TxtIngKey.SelStart = 0
  1047.    TxtIngKey.SelLength = Len(TxtIngKey.Text)
  1048.    Grid1.Col = 0
  1049. End Sub
  1050. Sub TxtIngKey_KeyDown (KeyCode As Integer, Shift As Integer)
  1051.   If KeyCode = KEY_F4 Then    ' Display key combinations.
  1052.     If TxtDesc.Text <> "" Then
  1053.       TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
  1054.       TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
  1055.     End If
  1056.   End If
  1057.   If KeyCode = KEY_UP Then
  1058.     ScrollGridUp
  1059.     If Grid1.Text <> "" Then
  1060.       Grid1.Col = 0
  1061.       RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
  1062.       RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
  1063.       DetailSaved = True
  1064.     Else
  1065.       DetailSaved = False
  1066.     End If
  1067.     KeyCode = 0
  1068.   ElseIf KeyCode = KEY_DOWN Then
  1069.     ScrollGridDown
  1070.     If Grid1.Text <> "" Then
  1071.       Grid1.Col = 0
  1072.       RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
  1073.       RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
  1074.       DetailSaved = True
  1075.     Else
  1076.       DetailSaved = False
  1077.     End If
  1078.     KeyCode = 0
  1079.   End If
  1080. End Sub
  1081. Sub TxtIngKey_KeyPress (KeyAscii As Integer)
  1082.   If KeyAscii = 13 Then
  1083.     If TxtIngKey.Text <> "" Then
  1084.       IngredientRec.IngKey = TxtIngKey.Text + String$(18 - Len(TxtIngKey.Text), " ")
  1085.       TxtIngKey.Text = IngredientRec.IngKey
  1086.       ReadIngredient
  1087.       Select Case IngredientSt%
  1088.     Case 0
  1089.       LblIngDesc.Caption = IngredientRec.IngDesc
  1090.       LblIngUnitDesc.Caption = IngredientRec.IngUnitDesc
  1091.       TxtUnits.SetFocus
  1092.     Case 3
  1093.       MsgIngredientNotOpen
  1094.       TxtUnits.SetFocus
  1095.     Case 4
  1096.       MsgIngredientNotFound
  1097.       TxtIngKey.SetFocus
  1098.       TxtIngKey.SelStart = 0
  1099.       TxtIngKey.SelLength = Len(TxtIngKey.Text)
  1100.       Grid1.Col = 0
  1101.     Case Else
  1102.       MsgUnknownIngredientError
  1103.       TxtUnits.SetFocus
  1104.       End Select
  1105.       KeyAscii = 0
  1106.     Else
  1107.       Msg$ = "Ingredient number is required."
  1108.       T1% = MsgBox(Msg$, 0, "Note")
  1109.       KeyAscii = 0
  1110.       TxtIngKey.SetFocus
  1111.     End If
  1112.   Else
  1113.     StrKP TxtIngKey, 18, KeyAscii
  1114.     KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
  1115.   End If
  1116. End Sub
  1117. Sub TxtKey_Change ()
  1118.   If EntryMode = "U" Then
  1119.     EntryMode = "C"
  1120.     SetCmdFlags
  1121.   End If
  1122. End Sub
  1123. Sub TxtKey_GotFocus ()
  1124.   ClearAllFields
  1125.   If ActiveTransaction Then
  1126.     AbortTransaction
  1127.   End If
  1128. End Sub
  1129. Sub TxtKey_KeyDown (KeyCode As Integer, Shift As Integer)
  1130.     If KeyCode = KEY_F4 Then    ' Display key combinations.
  1131.       If TxtDesc.Text <> "" Then
  1132.     TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
  1133.     TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
  1134.       End If
  1135.     End If
  1136.     If KeyCode = KEY_PAGE_UP Then
  1137.     CmdPrevious_Click
  1138.     End If
  1139.     If KeyCode = KEY_PAGE_DOWN Then
  1140.     CmdNext_Click
  1141.     End If
  1142. End Sub
  1143. Sub TxtKey_KeyPress (KeyAscii As Integer)
  1144.   If KeyAscii = 13 Then
  1145.     If TxtKey.Text <> "" Then
  1146.       Screen.MousePointer = 11
  1147.       BeginTransaction
  1148.       KeyAscii = 0
  1149.       EntryMode = "N"
  1150.       RecipeRec.RecNo = TxtKey.Text + String$(6 - Len(TxtKey.Text), " ")
  1151.       ReadRecipe
  1152.       Select Case RecipeSt%
  1153.     Case 0
  1154.       RecipeSaveRec = RecipeRec
  1155.       DisplayDataFields
  1156.       ReadAllRecipeDet
  1157.     Case 3
  1158.       Screen.MousePointer = 0
  1159.       MsgRecipeNotOpen
  1160.     Case 4
  1161.       RecipeRec.UpdateFlag = " "
  1162.       ClearDataFields
  1163.       TxtDesc.SetFocus
  1164.     Case Else
  1165.       Screen.MousePointer = 0
  1166.       MsgUnknownRecipeError
  1167.       End Select
  1168.       SetCmdFlags
  1169.       Screen.MousePointer = 0
  1170.     Else
  1171.       TxtKey.SetFocus
  1172.     End If
  1173.   Else
  1174.     UCStrKP TxtKey, 6, KeyAscii
  1175.   End If
  1176. End Sub
  1177. Sub TxtLife_Change ()
  1178.   If EntryMode = "U" Then
  1179.     EntryMode = "C"
  1180.     SetCmdFlags
  1181.   End If
  1182. End Sub
  1183. Sub TxtLife_GotFocus ()
  1184.   TxtLife.SelStart = 0
  1185.   TxtLife.SelLength = Len(TxtLife.Text)
  1186. End Sub
  1187. Sub TxtLife_KeyDown (KeyCode As Integer, Shift As Integer)
  1188.     If KeyCode = KEY_F4 Then    ' Display key combinations.
  1189.       If TxtDesc.Text <> "" Then
  1190.     TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
  1191.     TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
  1192.       End If
  1193.     End If
  1194.     If KeyCode = KEY_PAGE_UP Then
  1195.     CmdPrevious_Click
  1196.     End If
  1197.     If KeyCode = KEY_PAGE_DOWN Then
  1198.     CmdNext_Click
  1199.     End If
  1200. End Sub
  1201. Sub TxtLife_KeyPress (KeyAscii As Integer)
  1202.   If KeyAscii = 13 Then
  1203.     KeyAscii = 0
  1204.     TxtIngKey.SetFocus
  1205.   Else
  1206.     IntKP TxtLife, 2, KeyAscii
  1207.   End If
  1208. End Sub
  1209. Sub TxtMaintCode_Change ()
  1210.   If EntryMode = "U" Then
  1211.     EntryMode = "C"
  1212.     SetCmdFlags
  1213.   End If
  1214. End Sub
  1215. Sub TxtMaintCode_GotFocus ()
  1216.   TxtMaintCode.SelStart = 0
  1217.   TxtMaintCode.SelLength = Len(TxtMaintCode.Text)
  1218. End Sub
  1219. Sub TxtMaintCode_KeyDown (KeyCode As Integer, Shift As Integer)
  1220.     If KeyCode = KEY_F4 Then    ' Display key combinations.
  1221.       If TxtDesc.Text <> "" Then
  1222.     TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
  1223.     TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
  1224.       End If
  1225.     End If
  1226.     If KeyCode = KEY_PAGE_UP Then
  1227.     CmdPrevious_Click
  1228.     End If
  1229.     If KeyCode = KEY_PAGE_DOWN Then
  1230.     CmdNext_Click
  1231.     End If
  1232. End Sub
  1233. Sub TxtMaintCode_KeyPress (KeyAscii As Integer)
  1234.   If KeyAscii = 13 Then
  1235.     Select Case TxtMaintCode.Text
  1236.       Case "N", "D", "M"   'Round to nine
  1237.     TxtLife.SetFocus
  1238.       Case Else
  1239.     Msg$ = "Maint Code must be:" + Chr$(10)
  1240.     Msg$ = Msg$ + "N - Round to nine" + Chr$(10)
  1241.     Msg$ = Msg$ + "D - Round to dollar 99" + Chr$(10)
  1242.     Msg$ = Msg$ + "M - Manual calculation"
  1243.     T1% = MsgBox(Msg$, 0, "Note!")
  1244.     TxtMaintCode.Text = ""
  1245.     End Select
  1246.     KeyAscii = 0
  1247.   Else
  1248.     StrKP TxtMaintCode, 1, KeyAscii
  1249.     KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
  1250.   End If
  1251. End Sub
  1252. Sub TxtRetail_Change ()
  1253.   If EntryMode = "U" Then
  1254.     EntryMode = "C"
  1255.     SetCmdFlags
  1256.   End If
  1257. End Sub
  1258. Sub TxtRetail_GotFocus ()
  1259.   TxtRetail.SelStart = 0
  1260.   TxtRetail.SelLength = Len(TxtRetail.Text)
  1261. End Sub
  1262. Sub TxtRetail_KeyDown (KeyCode As Integer, Shift As Integer)
  1263.     If KeyCode = KEY_F4 Then    ' Display key combinations.
  1264.       If TxtDesc.Text <> "" Then
  1265.     TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
  1266.     TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
  1267.       End If
  1268.     End If
  1269.     If KeyCode = KEY_PAGE_UP Then
  1270.     CmdPrevious_Click
  1271.     End If
  1272.     If KeyCode = KEY_PAGE_DOWN Then
  1273.     CmdNext_Click
  1274.     End If
  1275. End Sub
  1276. Sub TxtRetail_KeyPress (KeyAscii As Integer)
  1277.   If KeyAscii = 13 Then
  1278.     KeyAscii = 0
  1279.     CalculateTotals
  1280.     If CmdUpdate.Enabled = True Then
  1281.       CmdUpdate.SetFocus
  1282.       If CInt(Val(TxtRetail.Text) * 100) <> RecipeSaveRec.RecRetail Then
  1283.     RecipeRec.UpdateFlag = "C"
  1284.       Else
  1285.     RecipeRec.UpdateFlag = " "
  1286.       End If
  1287.     Else
  1288.       RecipeRec.UpdateFlag = "A"
  1289.       TxtYields.SetFocus
  1290.     End If
  1291.   Else
  1292.     Curr2KP TxtRetail, 5, KeyAscii
  1293.   End If
  1294. End Sub
  1295. Sub TxtTarget_Change ()
  1296.   If EntryMode = "U" Then
  1297.     EntryMode = "C"
  1298.     SetCmdFlags
  1299.   End If
  1300. End Sub
  1301. Sub TxtTarget_GotFocus ()
  1302.   TxtTarget.SelStart = 0
  1303.   TxtTarget.SelLength = Len(TxtTarget.Text)
  1304. End Sub
  1305. Sub TxtTarget_KeyDown (KeyCode As Integer, Shift As Integer)
  1306.     If KeyCode = KEY_F4 Then    ' Display key combinations.
  1307.       If TxtDesc.Text <> "" Then
  1308.     TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
  1309.     TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
  1310.       End If
  1311.     End If
  1312.     If KeyCode = KEY_PAGE_UP Then
  1313.     CmdPrevious_Click
  1314.     End If
  1315.     If KeyCode = KEY_PAGE_DOWN Then
  1316.     CmdNext_Click
  1317.     End If
  1318. End Sub
  1319. Sub TxtTarget_KeyPress (KeyAscii As Integer)
  1320.   If KeyAscii = 13 Then
  1321.     KeyAscii = 0
  1322.     TxtMaintCode.SetFocus
  1323.   Else
  1324.     Curr2KP TxtTarget, 6, KeyAscii
  1325.   End If
  1326. End Sub
  1327. Sub TxtTarget_LostFocus ()
  1328.    t@ = Curr2LF(TxtTarget, .01, 100)
  1329. End Sub
  1330. Sub TxtUnits_Change ()
  1331.   If EntryMode = "U" Then
  1332.     EntryMode = "C"
  1333.     SetCmdFlags
  1334.   End If
  1335. End Sub
  1336. Sub TxtUnits_GotFocus ()
  1337.    TxtUnits.SelStart = 0
  1338.    TxtUnits.SelLength = Len(TxtUnits.Text)
  1339.    Grid1.Col = 2
  1340. End Sub
  1341. Sub TxtUnits_KeyDown (KeyCode As Integer, Shift As Integer)
  1342.   If KeyCode = KEY_F4 Then    ' Display key combinations.
  1343.     If TxtDesc.Text <> "" Then
  1344.       TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
  1345.       TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
  1346.     End If
  1347.   End If
  1348.   If KeyCode = KEY_UP Then
  1349.     ScrollGridUp
  1350.     If Grid1.Text <> "" Then
  1351.       Grid1.Col = 0
  1352.       RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
  1353.       RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
  1354.       DetailSaved = True
  1355.     Else
  1356.       DetailSaved = False
  1357.     End If
  1358.     KeyCode = 0
  1359.     TxtIngKey.SetFocus
  1360.   ElseIf KeyCode = KEY_DOWN Then
  1361.     ScrollGridDown
  1362.     If Grid1.Text <> "" Then
  1363.       Grid1.Col = 0
  1364.       RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
  1365.       RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
  1366.       DetailSaved = True
  1367.     Else
  1368.       DetailSaved = False
  1369.     End If
  1370.     KeyCode = 0
  1371.     TxtIngKey.SetFocus
  1372.   End If
  1373. End Sub
  1374. Sub TxtUnits_KeyPress (KeyAscii As Integer)
  1375.   If KeyAscii = 13 Then
  1376.     If TxtUnits.Text <> "" Then
  1377.       If DetailSaved Then
  1378.     RecipeDetRec.RecDetKey = RecipeDetSaveRec.RecDetKey
  1379.     ReadRecipeDet
  1380.     DeleteRecipeDet
  1381.       End If
  1382.       RecipeDetRec.RecDetKey = RecipeRec.RecNo + IngredientRec.IngKey
  1383.       RecipeDetRec.RecDetQty = Val(TxtUnits.Text)
  1384.       WriteRecipeDet
  1385.       Select Case RecipeDetSt%
  1386.     Case 0
  1387.       KeyAscii = 0
  1388.       TxtIngKey.SetFocus
  1389.       If Grid1.Row = Grid1.Rows - 1 Then
  1390.         Grid1.AddItem "", Grid1.Rows
  1391.         Grid1.RowHeight(Grid1.Row + 1) = Grid1.Height / 6.47
  1392.       End If
  1393.       Grid1.Col = 0
  1394.       Grid1.Text = TxtIngKey.Text
  1395.       Grid1.Col = 1
  1396.       Grid1.Text = RTrim$(IngredientRec.IngDesc)
  1397.       Grid1.Col = 2
  1398.       Grid1.Text = TxtUnits.Text
  1399.       Grid1.Col = 3
  1400.       Grid1.Text = RTrim$(IngredientRec.IngUnitDesc)
  1401.       Cost& = IngredientRec.IngCaseCost / IngredientRec.IngUnitsPerCase
  1402.       Cost& = Cost& * Val(TxtUnits.Text)
  1403.       LblIngCost.Caption = Format$(Cost& / 10000, "###.0000")
  1404.       Grid1.Col = 4
  1405.       Grid1.Text = LblIngCost.Caption
  1406.       ScrollGridDown
  1407.       If Grid1.Text <> "" Then
  1408.         Grid1.Col = 0
  1409.         RecipeDetSaveRec.RecDetKey = RecipeRec.RecNo + Grid1.Text
  1410.         RecipeDetSaveRec.RecDetQty = Val(TxtUnits.Text)
  1411.         DetailSaved = True
  1412.       Else
  1413.         DetailSaved = False
  1414.       End If
  1415.       CalculateTotals
  1416.     Case 5
  1417.       MsgRecipeDetDuplicate
  1418.       TxtUnits.Text = ""
  1419.       TxtIngKey.SetFocus
  1420.     Case Else
  1421.       MsgUnknownRecipeDetError
  1422.       End Select
  1423.     Else
  1424.       Msg$ = "Quantity is required."
  1425.       T1% = MsgBox(Msg$, 0, "Note")
  1426.       KeyAscii = 0
  1427.       TxtUnits.SetFocus
  1428.     End If
  1429.   Else
  1430.     Curr2KP TxtUnits, 6, KeyAscii
  1431.   End If
  1432. End Sub
  1433. Sub TxtYields_Change ()
  1434.   If EntryMode = "U" Then
  1435.     EntryMode = "C"
  1436.     SetCmdFlags
  1437.   End If
  1438. End Sub
  1439. Sub TxtYields_GotFocus ()
  1440.   TxtYields.SelStart = 0
  1441.   TxtYields.SelLength = Len(TxtYields.Text)
  1442. End Sub
  1443. Sub TxtYields_KeyDown (KeyCode As Integer, Shift As Integer)
  1444.     If KeyCode = KEY_F4 Then    ' Display key combinations.
  1445.       If TxtDesc.Text <> "" Then
  1446.     TxtDesc.Text = TxtDesc.Text + String$(30 - Len(TxtDesc.Text), " ")
  1447.     TxtDesc.Text = Left$(TxtDesc.Text, 24) + "DELETE"
  1448.       End If
  1449.     End If
  1450.     If KeyCode = KEY_PAGE_UP Then
  1451.     CmdPrevious_Click
  1452.     End If
  1453.     If KeyCode = KEY_PAGE_DOWN Then
  1454.     CmdNext_Click
  1455.     End If
  1456. End Sub
  1457. Sub TxtYields_KeyPress (KeyAscii As Integer)
  1458.   If KeyAscii = 13 Then
  1459.     KeyAscii = 0
  1460.     TxtTarget.SetFocus
  1461.     CalculateTotals
  1462.   Else
  1463.     IntKP TxtYields, 3, KeyAscii
  1464.   End If
  1465. End Sub
  1466.